home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Sample Controls / BDiamond / CBaseEventServer.h < prev    next >
Encoding:
Text File  |  1996-12-20  |  3.3 KB  |  89 lines  |  [TEXT/CWIE]

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. //    CBaseEventServer.h
  4. //
  5. //    This is a mix-in class that provides your control with basic
  6. //    message sending capabilities.
  7. //
  8. //    To Use this class:
  9. //    1.    Your control should (multiply) inherit from CBaseEventServer.
  10. //    2.    Call AddOutGoingInterface in the constructor of your control.
  11. //        This sets up a connection point for (each) outgoing interface that
  12. //        you want your EventServer to support.  Right now, it only supports
  13. //        a single interface -- if you call AddOutGoingInterface more than once,
  14. //        you'll fail an assertion.  AddOutGoingInterface must be called before
  15. //        SetUpConnectionPoints (read on...).
  16. //    3.    Call SetUpConnectionPoints in your constructor, after calling
  17. //        AddOutGoingInterface.
  18. //    4.    Override QueryInterface, and sure to call 
  19. //        CBaseEventServer::QueryInterface from within your override. Do not
  20. //        depend on CBaseEventServer::QueryInterface calling
  21. //        CBaseCOM::QueryInterface, even though it inherits from CBaseCOM.  Call
  22. //        CBaseControl::QueryInterface inside your override instead.
  23. //    5.    You do NOT need to override FireEvent, as you normally would to 
  24. //        fire events -- you get this now as part of CBaseEventServer.
  25. //        Remove your override if you're retrofitting a control that already
  26. //        sends events.  Of course, you still need to override FireOneEvent
  27. //        for the event(s) you're sending.
  28. //
  29.  
  30. #ifndef __CBaseEventServer__
  31. #define __CBaseEventServer__
  32.  
  33. #include "BDInterfaces.h"
  34. #include "CBaseCOM.h"
  35.  
  36. class CCPContainer;
  37. class IConnectionPointContainer;
  38.  
  39. ///////////////////////////////////////////////////////////////////////////////
  40. //
  41. // constants
  42. //
  43.  
  44. // we currently only support one connection at a time
  45. const short NUM_EVENT_SERVER_CONNECTIONS = 1;
  46.  
  47. ///////////////////////////////////////////////////////////////////////////////
  48. //
  49. // class declaration
  50. //
  51.  
  52. class CBaseEventServer : public CBaseCOM
  53. {
  54. public:
  55.     
  56.     // Initialization
  57.     CBaseEventServer(void);
  58.     ~CBaseEventServer();
  59.  
  60.     //  *** IUnknown methods ***
  61.     STDMETHOD (QueryInterface)(REFIID inRefID, void** outObj);
  62.     STDMETHOD_ (Uint32, AddRef)(void) { return CBaseCOM::AddRef(); }
  63.     STDMETHOD_ (Uint32, Release)(void) { return CBaseCOM::Release(); }
  64.     
  65. protected:
  66.     virtual Boolean AddOutGoingInterface(IID outgoingInterfaceID);
  67.     virtual void SetUpConnectionPoints(void);
  68.  
  69.     // These methods are usually rewritten for each of the other samples.
  70.     STDMETHOD (FireEvent) (REFIID refID, long eventID, PlatformEvent * event);
  71.     STDMETHOD (FireOneEvent)(REFIID refID, long eventID, IUnknown * eventTarget, EventRecord * event) PURE;
  72.  
  73. protected:
  74.     IID                                mOutgoingInterfaceID; // eventually we need a list of these...
  75.     CCPContainer *                    mCPContainerObj;
  76.     
  77.     // This member is a duplicate of the one in CBaseControl, which is used
  78.     // in CBaseControl's QueryInterface.  It's here in CBaseEventServer because
  79.     // we need the same instance variable, but we don't want CBaseEventServer
  80.     // to inherit from CBaseControl to get it.  Ideally, we should MOVE it
  81.     // out of CBaseControl into CBaseEventServer, but that would require a
  82.     // retrofit of all controls that already send events without inheriting from
  83.     // CBaseEventServer.  Right now we're duplicating the QueryInterface in this
  84.     // mix-in to avoid requiring a retrofit.
  85.     IConnectionPointContainer *        mCPContainerP;
  86. };
  87.  
  88. #endif // __CBaseEventServer__
  89.